package com.lbd;

import com.lbd.common.to.SkuHasStockVo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ProjectName: gulimall
 * @Package: com.lbd
 * @ClassName: Demo
 * @Author: linbd
 * @Description:
 * @Date: 2021/6/4 10:06
 */
public class Demo {
    public static void main(String[] args) {
        List<SkuHasStockVo> skuHasStockVos = new ArrayList<>();
        SkuHasStockVo skuHasStockVo1 = new SkuHasStockVo();
        skuHasStockVo1.setSkuId(1l);
        skuHasStockVo1.setHasStock(true);
        SkuHasStockVo skuHasStockVo2 = new SkuHasStockVo();
        skuHasStockVo2.setSkuId(2l);
        skuHasStockVo2.setHasStock(true);
        SkuHasStockVo skuHasStockVo3 = new SkuHasStockVo();
        skuHasStockVo3.setSkuId(3l);
        skuHasStockVo3.setHasStock(false);
        skuHasStockVos.add(skuHasStockVo1);
        skuHasStockVos.add(skuHasStockVo2);
        skuHasStockVos.add(skuHasStockVo3);
        Map<Long, Boolean> collect = skuHasStockVos.stream()
                .collect(Collectors.toMap(key -> key.getSkuId(), value -> value.getHasStock()));
        System.out.println(collect);
    }
}
